﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.RobotJog.Controls.Joints.CUiComponentNodeData
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows.Media;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.RobotJog.Controls.Joints;

public class CUiComponentNodeData : CUiNodeData
{
  private List<CUiNodeData> m_childrenNodes = new List<CUiNodeData>();

  public CUiComponentNodeData(CApRJRobotJogJointsLogic jointJogApplication, ITxComponent component)
    : base(jointJogApplication, (ITxObject) component, (ImageSource) null, ((ITxObject) component).Name)
  {
    this.m_nodeIcon = TxIconManager.the().GetObjectImageSource((ITxObject) component);
    if (!(this.NodeObject is ITxObjectCollection nodeObject))
      return;
    TxTypeFilter txTypeFilter1 = new TxTypeFilter(typeof (ITxComponent));
    foreach (ITxComponent directDescendant in (Collection<ITxObject>) nodeObject.GetDirectDescendants((ITxTypeFilter) txTypeFilter1))
    {
      if (directDescendant is ITxDevice device)
        this.m_childrenNodes.Add((CUiNodeData) this.m_jointJogApplication.GetDeviceNodeData(device));
      else if (directDescendant is ITxObjectCollection objectCollection)
      {
        TxTypeFilter txTypeFilter2 = new TxTypeFilter(typeof (ITxDevice));
        if (((Collection<ITxObject>) objectCollection.GetAllDescendants((ITxTypeFilter) txTypeFilter2)).Count > 0)
          this.m_childrenNodes.Add((CUiNodeData) this.m_jointJogApplication.GetComponentNodeData(directDescendant));
      }
    }
  }

  public ITxComponent NodeObject => base.NodeObject as ITxComponent;

  public List<CUiNodeData> ChildrenNodes => this.m_childrenNodes;

  public override void Dispose()
  {
    if (this.m_disposed)
      return;
    this.m_disposed = true;
    base.Dispose();
  }
}
